﻿using Abp.Configuration.Startup;
using Abp.Domain.Uow;
using FwProject.Configuration;
using FwProject.Web;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Text;

namespace FwProject.EntityFrameworkCore
{
  public  class FwConnectionStringResolver: DefaultConnectionStringResolver
    {
        public FwConnectionStringResolver(IAbpStartupConfiguration configuration)
          : base(configuration)
        {
        }

        public override string GetNameOrConnectionString(ConnectionStringResolveArgs args)
        {
            if (args["DbContextConcreteType"] as Type == typeof(FwProjectAppShopDbContext))
            {
                
                var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder());
                string conn= configuration.GetConnectionString(FwProjectConsts.AppShopDbConnectionStringName);
                return configuration.GetConnectionString(FwProjectConsts.AppShopDbConnectionStringName);
            }

            return base.GetNameOrConnectionString(args);
        }
    }
}
